home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / jaq / dist / jaquith.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-26  |  25.7 KB  |  791 lines

  1. /*
  2.  * jaquith.h --
  3.  *
  4.  *    DATA and declarations for use by the Jaquith archive system
  5.  *
  6.  * Copyright 1992 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that this copyright
  10.  * notice appears in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * Quote:
  16.  *      The primary purpose of the DATA statement is to give names to con-
  17.  *      stants; instead of referring to pi as 3.141592653589793 at every
  18.  *      appearance, the variable PI can be given that value with a DATA
  19.  *      statement and used instead of the longer form of the constant.
  20.  *      This also simplifies modifying the program, should the value of
  21.  *      pi change.
  22.  *      -- FORTRAN manual for Xerox Computers
  23.  *
  24.  * $Header: /sprite/lib/forms/RCS/jaquith.h,v 1.0 91/02/09 13:24:52 mottsmth Exp $ SPRITE (Berkeley)
  25.  */
  26.  
  27.  
  28. #ifndef _JAQUITH
  29. #define _JAQUITH
  30.  
  31. #ifdef OSF1
  32. #define _BSD
  33. #endif
  34. #include <stdio.h>
  35. #include <errno.h>
  36. #include <sys/types.h>
  37. #include <sys/file.h>
  38. #include <sys/stat.h>
  39. #include <sys/wait.h>
  40. #include <sys/param.h>
  41. #include <sys/time.h>
  42. #include <sys/timeb.h>
  43. #include <sys/socket.h>
  44. #include <sys/ioctl.h>
  45. #include <netinet/in.h>
  46. #include <netdb.h>
  47. #include <arpa/inet.h>
  48. #ifdef sunos
  49. #include <dirent.h>
  50. #else
  51. #include <sys/dir.h>
  52. #endif
  53. #ifdef SYSV
  54. #include <strings.h>
  55. #include <utime.h>
  56. #else
  57. #include <string.h>
  58. #endif
  59. #ifdef HASLIMITSH
  60. #include <limits.h>
  61. #else
  62. #define INT_MAX 2147483647
  63. #define SHRT_MAX 64535
  64. #endif
  65. #ifdef HASSTDLIBH
  66. #include <stdlib.h>
  67. #else
  68. extern int    exit();
  69. extern int    free();
  70. extern char *    getenv();
  71. extern char *    malloc();
  72. extern int    qsort();
  73. #endif
  74. #ifdef sprite
  75. #include <bstring.h>
  76. #endif
  77. #include <pwd.h>
  78. #include <grp.h>
  79. #include <time.h>
  80. #include <varargs.h>
  81. #include <signal.h>
  82. #include <ctype.h>
  83. #include "cfuncproto.h"
  84. #include "regexp.h"
  85.  
  86. #ifndef HASSTRTOK
  87. extern char *strtok();
  88. #endif
  89.  
  90. #define DEF_SERVER "covet.CS.Berkeley.EDU"
  91. #define DEF_PORT 10001
  92. #define DEF_MGRSERVER DEF_SERVER
  93. #define DEF_MGRPORT 20001
  94. #define DEF_DEVFILE "/jaquith/dev/devconfig"
  95. #define DEF_VOLFILE "/jaquith/dev/volconfig"
  96. #define DEF_ROBOT "/dev/exbjbox5"
  97. #define DEF_ARCH "default.arch"
  98. #define DEF_ROOT "/jaquith/arch"
  99. #define DEF_FSYNCFREQ 10
  100. #define DEF_JAQLOG "/jaquith/arch/jaq.log"
  101. #define DEF_MGRLOG "/jaquith/arch/jmgr.log"
  102. #define DEF_GET "/jaquith/cmds/jfetch"
  103. #define DEF_PUT "/jaquith/cmds/jupdate"
  104. #define DEF_CLEAN "/jaquith/cmds/jclean"
  105. #define DEF_STATUS "/jaquith/cmds/jquery"
  106. #define DEF_TBUFSIZE (1024*2048)  /* default tbuf size */
  107.  
  108. #define T_MAXMSGLEN 8192      /* arbitrary constant */
  109. #define T_MAXSTRINGLEN 1024   /* arbitrary constant */
  110. #define T_MAXLABELLEN 80      /* arbitrary constant */
  111. #define T_MAXPATHLEN 255      /* limited by POSIX tar format */
  112. #define T_MAXLINELEN 256      /* for config files */
  113. #define T_VOLSIZEK 4550000    /* 8500 Exabyte P6-120 */
  114. #define T_TAPEUNIT 1024       /* min write unit for device */
  115. #define T_FILEMARKSIZE (48*1024)  /* for Exb 8500 drive */
  116. #define T_BUFSIZE (32*T_TAPEUNIT) /*  socket/disk I/O operation size */
  117. #define T_TARSIZE (32*T_TAPEUNIT)  /* tar tape I/O operation size */
  118. #define T_TBLOCK 512          /* tar unit. not adjustable */
  119.  
  120. #define ARCHMASTER "mottsmth"
  121.  
  122. #define ROOT_LOGIN "root"
  123. #define COMMENT_CHAR '#'      /* For config file comments */
  124. #define ARCHLOGFILE "log"
  125. #define MSGVERSION 1          
  126. #define ENV_ARCHIVE_VAR "JARCHIVE"
  127. #define ENV_SERVER_VAR  "JSERVER"
  128. #define ENV_PORT_VAR    "JPORT"
  129.  
  130. typedef int AuthHandle;       /* for kerberos someday */
  131.  
  132. #ifdef MEMDEBUG
  133. #define MEM_ALLOC(name,amount) Mem_Alloc(name, __LINE__, amount)
  134. #define MEM_FREE(name, ptr) Mem_Free(name, __LINE__, (char *)ptr)
  135. #define MEM_CONTROL(size, stream, flags, freeMax) \
  136.     Mem_Control(size, stream, flags, freeMax)
  137. #define MEM_REPORT(name, owner, flags) \
  138.     Mem_Report(name, __LINE__, owner, flags)
  139. #else
  140. #define MEM_ALLOC(name,amount) malloc(amount)
  141. #define MEM_FREE(name, ptr) free((char *)ptr)
  142. #define MEM_CONTROL(size, stream, flags, freeMax) {}
  143. #define MEM_REPORT(name, owner, flags) {}
  144. #endif
  145.  
  146. #ifdef ultrix
  147. #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
  148. #endif
  149.  
  150. #ifdef sprite
  151. #define S_ISADIR(x) ((S_ISDIR(x)) || (S_ISRLNK(x)))
  152. #define S_ISALNK(x) ((S_ISLNK(x)) || (S_ISRLNK(x)))
  153. #define MAKERMTLINK(target, name, flag) Fs_SymLink(target, name, flag)
  154. #else
  155. #define S_ISADIR(x) (((x) & S_IFMT) == S_IFDIR)
  156. #define S_ISALNK(x) (((x) & S_IFMT) == S_IFLNK)
  157. #define S_IFRLNK 0160000
  158. #define MAKERMTLINK(target, name, flag) -1; \
  159.     printf("Don't know how to make remote link: %s\n", name);
  160. #endif
  161.  
  162. #if ((defined sunos) || (defined OSF1))
  163. typedef struct dirent DirObject;
  164. #else
  165. typedef struct direct DirObject;
  166. #endif
  167.  
  168. #if (defined(SYSV) && !defined(dynix))
  169. #define GETWD(path, pathLenPtr) getcwd(path, pathLenPtr)
  170. #else
  171. #define GETWD(path, pathLenPtr) getwd(path)
  172. #endif
  173.  
  174. extern int errno;
  175. extern int sys_nerr;
  176. extern char *sys_errlist[];
  177.  
  178. #ifdef SYSV
  179. #define STRCHR index
  180. #define STRRCHR rindex
  181. #else
  182. #define STRCHR strchr
  183. #define STRRCHR strrchr
  184. #endif
  185.  
  186. /*
  187.  * Message layouts
  188.  * 
  189.  * Each message from a T_CLIENT has a header and a body
  190.  * which is a descrimated union.
  191.  */
  192.  
  193. typedef struct T_ReqMsgHdr {
  194.     int version;              /* message version number */
  195.     int cmd;                  /* command type */
  196.     int len;                  /* length of following command data */
  197.     int flags;                /* misc flags */
  198.     AuthHandle ticket;        /* kerberos ticket */
  199. } T_ReqMsgHdr;
  200.  
  201. typedef struct T_RespMsgHdr {
  202.     int version;              /* message version number */
  203.     int len;                  /* length of following command data */
  204.     int status;               /* command status */
  205.     int errno;                /* system error number */
  206. } T_RespMsgHdr;
  207.  
  208. /*
  209.  * defines for command types. Jaquith depends on this order.
  210.  */
  211. #define T_MAXCMDS 5
  212.  
  213. #define T_CMDNULL 0
  214. #define T_CMDLS   1
  215. #define T_CMDPUT  2
  216. #define T_CMDGET  3
  217. #define T_CMDSTAT 4
  218.  
  219. /*
  220.  * defines for flags word
  221.  */
  222. #define T_LOCAL      0x01     /* Read data from local file */
  223. #define T_LINK       0x02     /* Return link itself */
  224. #define T_FOLLOWLINK 0x04     /* Return link's target */
  225. #define T_FORCE      0x08     /* Force data out to archive */
  226. #define T_SYNC       0x10     /* Write data synchronously to storage */
  227. #define T_NODATA     0x20     /* Return metadata only */
  228. #define T_NEWVOL     0x40     /* Force data to a new volume. */
  229. #define T_COMPRESS   0x80     /* Compress data before storing */
  230.  
  231. /*
  232.  * defines for status. Interpreted by MakeErrorMsg
  233.  */
  234. #define T_ACTIVE    -2
  235. #define T_FAILURE   -1
  236. #define T_SUCCESS    0
  237. #define T_BADVERSION 1
  238. #define T_BADMSGFMT  2
  239. #define T_BADCMD     3
  240. #define T_NOACCESS   4
  241. #define T_IOFAILED   5
  242. #define T_INDXFAILED 6
  243. #define T_BUFFAILED  7
  244. #define T_ADMFAILED  8
  245. #define T_ROBOTFAILED 9
  246. #define T_NOVOLUME   10
  247. #define T_EXECFAILED 11
  248. #define T_NOARCHIVE  12
  249. #define T_MAXERR   13
  250.  
  251. typedef struct T_FileStat {
  252.     char *fileName;           /* file name */
  253.     char *linkName;           /* target file name if this is a symlink */
  254.     char *uname;              /* user name */
  255.     char *gname;              /* group name */
  256.     char *abstract;           /* arbitrary user text string */
  257.     char *fileList;           /* List of filenames in a directory */
  258.     time_t vtime;             /* archive date/time */
  259.     time_t atime;             /* access date/time */
  260.     int volId;                /* volume number */
  261.     int filemark;             /* filemark number */
  262.     int tBufId;               /* buffer number */
  263.     int offset;               /* offset of file within buffer */
  264.     int mode;                 /* protection and type */
  265.     int uid;                  /* user id */
  266.     int gid;                  /* group id */
  267.     time_t mtime;             /* modification time */
  268.     int size;                 /* size in bytes. Should be larger */
  269.     dev_t rdev;               /* device id if this is a device */
  270. } T_FileStat;
  271.  
  272. typedef struct Caller {
  273.     char *userName;           /* User login name */
  274.     char *groupName;          /* User group name */
  275.     char *hostName;           /* Host name */
  276. } Caller;
  277.  
  278. /**************************** utils ****************************/
  279.  
  280. #define BAIL_PRINT  0
  281. #define BAIL_PERROR 1
  282. #define BAIL_HERROR 2
  283.  
  284. extern void  Utils_Bailout       _ARGS_ ((char *msg, int disposition));
  285. extern void  Utils_GetWorkingDir _ARGS_ ((char *path, int *pathLen));
  286. extern char *Utils_MakeFullPath  _ARGS_ ((char *name));
  287. extern int   Utils_CheckName     _ARGS_ ((char *name, int noWhiteSpace));
  288. extern char *Utils_ReadLine      _ARGS_ ((FILE *stream, int stripFlag));
  289. extern int   Utils_StringHashProc _ARGS_ ((Hash_Key key,int keyLen, int size));
  290. extern int   Utils_IntegerHashProc _ARGS_ ((Hash_Key key,int keyLen,int size));
  291. extern int   Utils_CvtInteger    _ARGS_ ((char *string, int low,
  292.                       int high, int *valPtr));
  293. extern char *Utils_GetLoginByUid _ARGS_ ((int uid));
  294. extern char *Utils_GetGroupByGid _ARGS_ ((int gid));
  295. extern int   Utils_GetUidByLogin _ARGS_ ((char *login));
  296. extern int   Utils_GetGidByGroup _ARGS_ ((char *group));
  297. extern int   Utils_SendMail      _ARGS_ ((char *recipient, char *msg,
  298.                       char *type));
  299. extern void  Utils_FreeFileStat  _ARGS_ ((T_FileStat *statInfoPtr, int flag));
  300. extern T_FileStat *Utils_CopyFileStat  _ARGS_ ((T_FileStat *statInfoPtr));
  301. extern int   Utils_GetOk         _ARGS_ ((char *msg));
  302. extern int   Utils_GetInteger    _ARGS_ ((char *msg, int low, int high));
  303.  
  304. /**************************** mem ****************************/
  305.  
  306. #define MEM_MAXALLOC 8*1024
  307.  
  308. extern char *Mem_Alloc   _ARGS_ ((char *callerName, int line, int blockSize));
  309. extern int   Mem_Free    _ARGS_ ((char *callerName, int line, char *blockPtr));
  310. extern char *Mem_Dup     _ARGS_ ((char *callerName, int line, char *string));
  311. extern char *Mem_Cat     _ARGS_ ((char *callerName, int line, int argCnt,...));
  312. extern void  Mem_Report  _ARGS_ ((char *callerName, int line,
  313.                   char *owner, int reportFlags));
  314. extern void  Mem_Control _ARGS_ ((int maxBlockSize, FILE *outStream,
  315.                   int traceFlags, int freeMax));
  316.  
  317. /*
  318.  * Bit definitions for traceFlags parameter
  319.  */
  320.  
  321. /*
  322.  * Enable tracing.
  323.  * Default: off
  324.  */
  325. #define TRACEMEM         0x01
  326.  
  327. /*
  328.  * print msg at each alloc and free call.
  329.  * Default: off
  330.  */
  331. #define TRACECALLS       0x02
  332.  
  333. /*
  334.  * print statistics for calling routine after each alloc and free call
  335.  * Default: off
  336.  */
  337. #define TRACESTATS       0x04
  338. /*
  339.  * check border around blocks for overwrite after each alloc/free call
  340.  * Default: off (each block is checked when it's freed.)
  341.  */
  342. #define CHECKALLBLKS     0x08
  343.  
  344. /*
  345.  * Blocks allocated while TRACEMEM == 0 will not be in the database.
  346.  * If later tracing is enabled and one of these blocks is freed,
  347.  * there will be no record of it in the database and JmsFree will abort.
  348.  * A similar problem occurs if only some of the code is instrumented so
  349.  * that only some allocs are traced.
  350.  * 
  351.  * Set IGNOREMISSINGBLK == 1 to ignore such blocks or WARNMISSINGBLK
  352.  * to print a message but continue. The bits are mutually exclusive.
  353.  * Default: issue message and abort (Both bits off).
  354.  */
  355. #define IGNOREMISSINGBLK 0x10
  356. #define WARNMISSINGBLK 0x20
  357.  
  358. /*
  359.  * for ownerName parameter
  360.  */
  361. #define ALLROUTINES "*"
  362.  
  363. /*
  364.  * report flags
  365.  */
  366. #define SORTBYREQ   0x01
  367. #define SORTBYADDR  0x02
  368. #define SORTBYOWNER 0x04
  369. #define SORTBYSIZE  0x08
  370.  
  371. /*
  372.  * Include freed blocks in report.
  373.  * default: off
  374.  */
  375. #define REPORTALLBLKS 0x10
  376.  
  377.  
  378. /**************************** str ****************************/
  379.  
  380. extern int   Str_Match     _ARGS_ ((char *s1, char *s2));
  381. extern char **Str_Split    _ARGS_ ((char *string, char splitChar, 
  382.                     int *partCnt, int elide,
  383.                     char **insidePtrPtr));
  384. extern char *Str_Dup       _ARGS_ ((char *string));
  385. extern char *Str_Cat       _ARGS_ ((int argCnt,...));
  386. extern char *Str_Quote     _ARGS_ ((char *src, char *metachars));
  387. extern int   Str_Unquote   _ARGS_ ((char *src));
  388. extern int   Str_StripDots _ARGS_ ((char *src));
  389.  
  390.  
  391. /**************************** tbuf ****************************/
  392.  
  393. #define MAXTBUFSIZE 1024*1024
  394. #define READING 0
  395. #define WRITING 1
  396.  
  397. extern int   TBuf_Open        _ARGS_ ((char *path, int name, int *fdPtr,
  398.                        int *hdrFdPtr, int mode));
  399. extern int   TBuf_Close       _ARGS_ ((int tBufFd, int tHdrFd,
  400.                        int termFlag));
  401. extern int   TBuf_Pad         _ARGS_ ((int tBufFd, int len, int blockSize));
  402. extern int   TBuf_WriteTarHdr _ARGS_ ((int fd, T_FileStat *inData));
  403. extern int   TBuf_ParseTarHdr _ARGS_ ((char *inBuf, T_FileStat *outData));
  404. extern int   TBuf_FindFile    _ARGS_ ((int tBufFd, T_FileStat *statInfoPtr));
  405. extern int   TBuf_Delete      _ARGS_ ((char *rootPath, char *arch,
  406.                        int firstTBuf, int lastTBuf));
  407.  
  408. extern int   TBuf_Terminate   _ARGS_ ((int tBufStream, int tBufSize,
  409.                        int unit));
  410.  
  411.  
  412. /**************************** lock ****************************/
  413.  
  414. typedef struct lock_handle {
  415.     int lockFd;
  416.     int lockMode;
  417.     char lockName[T_MAXPATHLEN];
  418. } Lock_Handle;
  419.  
  420. #define LOCK_BLOCK 0
  421. #define LOCK_NOBLOCK 1
  422. #define LOCK_RMCONFIRM 1
  423.  
  424. extern int  Lock_Acquire   _ARGS_ ((char *name, int blockFlag,
  425.                     Lock_Handle *handlePtr));
  426. extern int  Lock_Release   _ARGS_ ((Lock_Handle *handlePtr));
  427. extern void Lock_RemoveAll _ARGS_ ((char *dirPath, int confirmFlag));
  428.  
  429. /**************************** admin ****************************/
  430.  
  431. /*
  432.  * Archive's configuration state
  433.  */
  434. typedef struct archConfig {
  435.     char mgrServer[T_MAXSTRINGLEN]; /* name of jmgr server */
  436.     int mgrPort;              /* port where jmgr listens */
  437.     int tBufSize;             /* tbuf target size */
  438. } ArchConfig;
  439.  
  440. /*
  441.  * Archive's volume state
  442.  */
  443. typedef struct volinfo {
  444.     int volId;                /* current volume id */
  445.     int filemark;             /* Last filemark written. i.e EOD */
  446.     int volSpace;             /* remaining volume space in K bytes */
  447.     int lastTBuf;             /* last tBuf written. Should be 2*filemark*/
  448. } VolInfo;
  449.  
  450. /*
  451.  * Archive's buffer state
  452.  */
  453. typedef struct metaInfo {
  454.     int tBufSize;             /* Current size of buffer */
  455.     int tHdrSize;             /* Current size of buffer hdr */
  456.     int fileCnt;              /* Number of files in tBuf */
  457.     int tBufPad;              /* Pad on buffer for tar */
  458. } MetaInfo;
  459.  
  460. /*
  461.  * Volume's owner
  462.  */
  463. typedef struct volowner {
  464.     char *owner;              /* owning archive name */
  465.     int minTBuf;              /* first tbuf on volume */
  466.     int maxTBuf;              /* last tbuf on volume */
  467. } VolOwner;
  468.  
  469. /*
  470.  * Volume config file entry
  471.  */
  472. typedef struct volConfig {
  473.     int volId;                /* volume id */
  474.     int location;             /* location */
  475.     char volLabel[T_MAXLABELLEN]; /* name */
  476. } VolConfig;
  477.  
  478. /*
  479.  * Device config file entry
  480.  */
  481. typedef struct devConfig {
  482.     char name[T_MAXPATHLEN];  /* name of device */
  483.     int location;             /* location */
  484. } DevConfig;
  485.  
  486. extern int   Admin_CheckAuth     _ARGS_ ((char *archName, Caller callerPtr,
  487.                       char *permPtr));
  488. extern int   Admin_AddAuth       _ARGS_ ((char *archName, Caller callerPtr,
  489.                       char perm));
  490. extern int   Admin_ReadArchConfig _ARGS_ ((char *archName,
  491.                        ArchConfig *archConfigPtr));
  492. extern int   Admin_WriteArchConfig _ARGS_ ((char *archName,
  493.                         ArchConfig *archConfigPtr));
  494. extern int   Admin_GetCurTBuf    _ARGS_ ((char *archName, int *tBufIdPtr));
  495. extern int   Admin_SetCurTBuf    _ARGS_ ((char *archName, int tBufId));
  496. extern FILE *Admin_OpenVolInfo   _ARGS_ ((char *archName,
  497.                       Lock_Handle *lockHandlePtr));
  498. extern int   Admin_CloseVolInfo   _ARGS_ ((Lock_Handle *lockHandlePtr,
  499.                        FILE *volStream));
  500. extern int   Admin_ReadVolInfo   _ARGS_ ((FILE *volStream, VolInfo *archPtr));
  501. extern int   Admin_WriteVolInfo  _ARGS_ ((FILE *volStream, VolInfo *archPtr));
  502. extern int   Admin_AvailVolInfo  _ARGS_ ((char *archPath));
  503. extern FILE *Admin_OpenMetaInfo  _ARGS_ ((char *archName, int tBufId));
  504. extern int   Admin_CloseMetaInfo _ARGS_ ((FILE *metaStream));
  505. extern int   Admin_ReadMetaInfo  _ARGS_ ((FILE *metaStream, MetaInfo *archPtr));
  506. extern int   Admin_WriteMetaInfo _ARGS_ ((FILE *metaStream, MetaInfo *archPtr));
  507. extern int   Admin_CvtTBufId     _ARGS_ ((char *archPath, int tBufId,
  508.                       int *volIdPtr, int *blkIdPtr));
  509. extern int   Admin_UpdateLRU     _ARGS_ ((char *rootPath, char *archive,
  510.                       int tBufId));
  511. extern int   Admin_RemoveLRU     _ARGS_ ((char *rootPath, char *archive,
  512.                       int *tBufIdPtr));
  513. extern int   Admin_GetDiskUse    _ARGS_ ((char *filename,
  514.                       int *percentFreePtr,
  515.                       long *blocksFreePtr));
  516. extern VolOwner *Admin_FindVolOwner _ARGS_ ((int volId, char *root,
  517.                          char *archPattern));
  518. extern int   Admin_ReadDevConfig _ARGS_ ((char *root, DevConfig *list,
  519.                       int *cntPtr));
  520. extern int   Admin_WriteDevConfig _ARGS_ ((char *file, DevConfig *list,
  521.                        int cnt));
  522. extern int   Admin_ReadVolConfig _ARGS_ ((char *file, VolConfig *list,
  523.                       int *cntPtr));
  524. extern int   Admin_WriteVolConfig _ARGS_ ((char *file, VolConfig *list,
  525.                        int cnt));
  526. extern int   Admin_GetFreeVol     _ARGS_ ((char *root, int *volIdPtr));
  527. extern int   Admin_PutFreeVol     _ARGS_ ((char *root, int volId));
  528.  
  529. /**************************** hash ****************************/
  530.  
  531. #define MAXHASHSIZE 1000
  532.  
  533. typedef int Hash_ClientData;
  534. typedef char *Hash_Key;
  535.  
  536. typedef struct Hash_Node {
  537.     Hash_Key key;
  538.     int keyLen;
  539.     Hash_ClientData datum;
  540. } Hash_Node;
  541.  
  542. typedef struct Hash_Handle {
  543.     char *name;               /* name of table for debugging */
  544.     int tabSize;              /* # entries in hash table */
  545.     Hash_Node *tab;           /* hash table */
  546.     int stringSize;           /* size of string table */
  547.     char *stringTab;          /* ptr to string space */
  548.     int stringUsed;           /* amount of string space in use */
  549.     int (*hashFunc)();        /* hashing function */
  550.     int freeData;             /* 1==give dead data values to free() */
  551.     int tabGrowCnt;           /* statistics */
  552.     float tabFill;
  553.     int stringGrowCnt;
  554.     float stringFill;
  555.     int insertCnt;
  556.     int deleteCnt;
  557.     int lookupCnt;
  558.     int updateCnt;
  559.     int probeCnt;         
  560. } Hash_Handle;
  561.  
  562. typedef struct Hash_Stat {
  563.     int tabSize;              /* table space */
  564.     int tabGrowCnt;           /* number table reallocations */
  565.     float avgTabFill;         /* avg use at time of reallocation */
  566.     int stringSize;           /* string space */
  567.     int stringGrowCnt;        /* # of string table reallocations */
  568.     float avgStringFill;      /* avg use at time of reallocation */
  569.     int insertCnt;            /* # inserts done */
  570.     int deleteCnt;            /* # deletes done */
  571.     int lookupCnt;            /* # lookups done */
  572.     int updateCnt;            /* # updates done */
  573.     float avgProbeCnt;        /* avg # probes per operation */
  574. } Hash_Stat;
  575.  
  576. extern Hash_Handle *Hash_Create  _ARGS_ ((char *name, int size,
  577.                       int (*hashFunc)(),
  578.                       int freeData));
  579. extern void     Hash_Destroy _ARGS_ ((Hash_Handle *hashPtr));
  580. extern int      Hash_Insert  _ARGS_ ((Hash_Handle *hashPtr,
  581.                       Hash_Key key,
  582.                       int keyLen,
  583.                       Hash_ClientData datum));
  584. extern int      Hash_Delete  _ARGS_ ((Hash_Handle *hashPtr,
  585.                       Hash_Key key,
  586.                       int keyLen));
  587. extern int      Hash_Lookup  _ARGS_ ((Hash_Handle *hashPtr,
  588.                       Hash_Key key,
  589.                       int keyLen,
  590.                       Hash_ClientData *datumPtr));
  591. extern int      Hash_Update  _ARGS_ ((Hash_Handle *hashPtr,
  592.                       Hash_Key key,
  593.                       int keyLen,
  594.                       Hash_ClientData datum));
  595. extern void     Hash_Iterate _ARGS_ ((Hash_Handle *hashPtr, 
  596.                       int (*func)(),
  597.                       int *callVal));
  598. extern void     Hash_Stats   _ARGS_ ((Hash_Handle *hashPtr,
  599.                       Hash_Stat *statPtr));
  600.  
  601. #define HASH_ITER_REMOVE_STOP -3
  602. #define HASH_ITER_REMOVE_CONT -2
  603. #define HASH_ITER_STOP -1
  604. #define HASH_ITER_CONTINUE 0
  605.  
  606. /**************************** queue ****************************/
  607.  
  608. typedef int Q_ClientData;
  609.  
  610. typedef struct Q_Node {
  611.     struct Q_Node *link;
  612.     int priority;
  613.     Q_ClientData datum;
  614. } Q_Node;
  615.  
  616. typedef struct Q_Handle {
  617.     Q_Node *head;
  618.     Q_Node *tail;
  619.     int count;
  620.     int freeData;
  621.     char *name;
  622. } Q_Handle;
  623.  
  624. extern Q_Handle *   Q_Create  _ARGS_ ((char *qName, int freeData));
  625. extern void         Q_Destroy _ARGS_ ((Q_Handle *qPtr));
  626. extern void         Q_Add     _ARGS_ ((Q_Handle *qPtr,
  627.                        Q_ClientData clientData,
  628.                        int priority));
  629. extern Q_ClientData Q_Remove  _ARGS_ ((Q_Handle *qPtr));
  630. extern int          Q_Count   _ARGS_ ((Q_Handle *qPtr));
  631. extern Q_ClientData Q_Peek    _ARGS_ ((Q_Handle *qPtr));
  632. extern void         Q_Print   _ARGS_ ((Q_Handle *qPtr, FILE *fd));
  633. extern int          Q_Iterate _ARGS_ ((Q_Handle *qPtr,
  634.                        int (*func)
  635.                        (Q_Handle *,
  636.                     Q_ClientData *clientdata,
  637.                     int *,
  638.                     int *),
  639.                        int *callVal));
  640.  
  641. #define Q_TAILQ (int)INT_MAX
  642. #define Q_HEADQ (int)0
  643.  
  644. #define Q_ITER_REMOVE_STOP -3
  645. #define Q_ITER_REMOVE_CONT -2
  646. #define Q_ITER_STOP -1
  647. #define Q_ITER_CONTINUE 0
  648.  
  649.  
  650. /**************************** dev ****************************/
  651.  
  652. typedef struct VolStatus {
  653.     int speed;
  654.     int density;
  655.     int remaining;
  656.     int position;
  657.     int writeProtect;
  658. } VolStatus;
  659.  
  660. extern int   Dev_MoveVolume   _ARGS_ ((int stream, int src, int dest));
  661. extern int   Dev_OpenVolume   _ARGS_ ((char *name, int flags));
  662. extern int   Dev_CloseVolume  _ARGS_ ((int stream));
  663. extern int   Dev_ReadVolume   _ARGS_ ((int stream, char *buf, int cnt));
  664. extern int   Dev_WriteVolume  _ARGS_ ((int stream, char *buf, int cnt));
  665. extern int   Dev_UnloadVolume _ARGS_ ((char *devName));
  666. extern int   Dev_SeekVolume   _ARGS_ ((int stream, int blkId, int absolute));
  667. extern int   Dev_WriteEOF     _ARGS_ ((int stream, int count));
  668. extern int   Dev_ReadVolLabel _ARGS_ ((int stream, int location, char *label));
  669. extern int   Dev_CvtVolLabel  _ARGS_ ((char *label));
  670. extern int   Dev_InitRobot    _ARGS_ ((int stream));
  671. extern int   Dev_GetVolStatus _ARGS_ ((int stream, VolStatus *volStatusPtr));
  672. extern int   Dev_DisplayMsg   _ARGS_ ((int stream, char *msg, int style));
  673. extern int   Dev_OpenDoor     _ARGS_ ((int stream));
  674. extern int   Dev_RemoveVolume _ARGS_ ((int stream, int src));
  675. extern int   Dev_InsertVolume _ARGS_ ((int stream, int dest));
  676.  
  677. #define DEV_RELATIVE 0
  678. #define DEV_ABSOLUTE 1
  679.  
  680. /**************************** sock ****************************/
  681.  
  682. extern int  Sock_SetupSocket  _ARGS_ ((int port, char *server,
  683.                        int dieFlag));
  684. extern int  Sock_SetupEarSocket  _ARGS_ ((int *portPtr));
  685. extern void Sock_SetSocket    _ARGS_ ((int sock, char *bufPtr, int bufSize));
  686. extern int  Sock_ReadSocket   _ARGS_ ((int sock));
  687. extern int  Sock_SendRespHdr  _ARGS_ ((int sock, int, int));
  688. extern void Sock_ReadRespHdr  _ARGS_ ((int sock, T_RespMsgHdr *resp));
  689.  
  690. extern int  Sock_ReadInteger  _ARGS_ ((int sock, int *intPtr));
  691. extern int  Sock_ReadShort    _ARGS_ ((int sock, short *shortPtr));
  692. extern int  Sock_ReadString   _ARGS_ ((int sock, char **bufPtr,
  693.                        int bufLen));
  694. extern int  Sock_ReadNBytes   _ARGS_ ((int sock, char *buf, int bufLen));
  695.  
  696. extern int  Sock_WriteInteger _ARGS_ ((int sock, int val));
  697. extern int  Sock_WriteShort   _ARGS_ ((int sock, int shortVal));
  698. extern int  Sock_WriteString  _ARGS_ ((int sock, char *buf, int bufLen));
  699. extern int  Sock_WriteNBytes  _ARGS_ ((int sock, char *buf, int bufLen));
  700. extern char *Sock_PackData    _ARGS_ ((char *fmt, char **objArray,
  701.                        int *packedLenPtr));
  702. extern int  Sock_UnpackData   _ARGS_ ((char *fmt, char *buf,
  703.                        int *countPtr, char **objArray));
  704. extern void Sock_SendReqHdr   _ARGS_ ((int sock, int cmd,
  705.                        AuthHandle ticket, int recurse,
  706.                        char *mail, char *arch,int force));
  707.  
  708. /**************************** ttime ****************************/
  709.  
  710. long   Time_Stamp       _ARGS_ (());
  711. time_t Time_GetCurDate  _ARGS_ (());
  712. int    Time_Compare     _ARGS_ ((time_t time1, time_t time2,
  713.                  int dateOnly));
  714. char  *Time_CvtToString _ARGS_ ((time_t *time));
  715. int    getindate        _ARGS_ ((char *datePtr, struct timeb *timebPtr));
  716. int    getindatepair    _ARGS_ ((char *datePtr, struct timeb *timebPtr1,
  717.                  struct timeb *timePtr2));
  718.  
  719. /**************************** tlog ****************************/
  720.  
  721. #define LOG_FAIL 0x01
  722. #define LOG_MAJOR 0x02
  723. #define LOG_MINOR 0x04
  724. #define LOG_TRACE 0x08
  725. #define LOG_MAX_DETAIL 4
  726.  
  727. extern int   Log_Event      _ARGS_ ((char *src, char *msg, int level));
  728. extern int   Log_Open       _ARGS_ ((char *logName));
  729. extern int   Log_Close      _ARGS_ (());
  730. extern void  Log_SetDetail  _ARGS_ ((int detail));
  731. extern int   Log_AtomicEvent _ARGS_ ((char *src, char *msg, char *logName));
  732.  
  733. /**************************** indx ****************************/
  734.  
  735. typedef struct QuerySpec {
  736.     int firstVer;
  737.     int lastVer;
  738.     time_t firstDate;
  739.     time_t lastDate;
  740.     char *owner;
  741.     char *group;
  742.     int flags;
  743.     int recurse;
  744.     regexp *compAbstract;
  745.     char *fileName;
  746. } QuerySpec;
  747.  
  748. /* queryspec.flags definitions */
  749. #define QUERY_MODDATE 0x01
  750.  
  751. int   Indx_Open     _ARGS_ ((char *pathName, char *openOptions,
  752.                  FILE **indxStrPtr));
  753. int   Indx_Close    _ARGS_ ((FILE *str));
  754. int   Indx_Read     _ARGS_ ((char *fileName, T_FileStat *statInfoPtr,
  755.                  FILE *indxStream));
  756. int   Indx_MakeIndx _ARGS_ ((char *archPath, char *filePath, char *indxPath));
  757. int   Indx_MakeIndxList _ARGS_ ((char *archPath, char *filePath,
  758.                  Q_Handle *indxQueue));
  759. int   Indx_Match    _ARGS_ ((QuerySpec *spec, char *indxPath, char *archPath,
  760.                  char *userName, char *groupName, 
  761.                  int (*receiveProc)(), ReceiveBlk *receiveBlkPtr,
  762.                  int ignoreDir));
  763. int   Indx_ReadIndxEntry _ARGS_ ((FILE *indxStream, T_FileStat *statInfoPtr));
  764. int   Indx_WriteIndxEntry _ARGS_ ((T_FileStat *statInfoPtr, int thdrStream,
  765.                    FILE *indxStream));
  766.  
  767.  
  768. /**************************** jmgr ****************************/
  769.  
  770. #define S_CMDNULL 0
  771. #define S_CMDLOCK 1
  772. #define S_CMDFREE 2
  773. #define S_CMDSTAT 3
  774.  
  775. typedef struct s_devstat {
  776.     int count;
  777.     char *devName;
  778.     int volId;
  779.     char *hostName;
  780.     char *userName;
  781. } S_DevStat;
  782.  
  783. typedef struct s_qstat {
  784.     int count;
  785.     int volId;
  786.     char *hostName;
  787. } S_QStat;
  788.  
  789. #endif /* _JAQUITH */
  790.  
  791.